<?php
    include_once('../../src/classes/class.mysql.php');
    
    session_start();
    
    $comtec_id_mainteiner = $_GET["id"];
    
    $db = new MySQL();
    
    $tsql = "SELECT comtec_id_configman, configman_name, maintainment_period, maintainment_period_date, maintainment_day";  
    $tsql .= " FROM configman WHERE comtec_id_mainteiner=$comtec_id_mainteiner and status_reg=1 ORDER BY configman_name ASC";
    
    $stmt = $db->query($tsql);       
    
    $texto  =  "<table class='table'>";
     if($_SESSION["users"]=="managers"){
       $texto .=  "<tr><th colspan=2></th>";
     }elseif ($_SESSION["users"]!="clients" && $_SESSION["users"]!="technicians") {
       $texto .= "<tr><th></th>";       
     }
    $texto .=  "<th>C&oacute;digo</th>
              <th>Nombre</th>
              <th>Periodo Mant.</th>
              <th>Detalle Mant.</th>
              <th>D&iacute;a del mes Mant.</th>
              </tr>";  
    $cont = 0;
    
    while ($row = mysql_fetch_array($stmt, MYSQL_ASSOC)){
     $cont += 1;
     $comtec_id_configman=$row['comtec_id_configman'];   
     $configman_name=$row['configman_name'];
     $maintainment_period=$row['maintainment_period'];
     $maintainment_period_date=$row['maintainment_period_date'];
     $maintainment_day=$row['maintainment_day'];
     $texto .= "<tr>";
     if($_SESSION["users"]!="clients" && $_SESSION["users"]!="technicians"){
      $url_edit='http://'.$_SERVER['HTTP_HOST'].'/iconos/edit.png';
      $texto .= "<td><a href='javascript:loadConfigman(".$comtec_id_configman.");'><img src='$url_edit' alt='editar' style='border: 0px;' /></a></td>";
     }
     if($_SESSION["users"]=="managers"){ 
      $url_delete='http://'.$_SERVER['HTTP_HOST'].'/iconos/delete.png';
      $texto .= "<td><a href='javascript:deleteConfigman(".$comtec_id_configman.");'><img src='$url_delete' alt='eliminar' style='border: 0px;' /></a></td>";
     }
     $texto .= "<td><a href='javascript:configman(".$comtec_id_configman.");'>$comtec_id_configman</a></td>";
     $texto .= "<td>$configman_name</td>";
     $texto .= "<td>$maintainment_period</td>";
     $texto .= "<td>$maintainment_period_date</td>";
     $texto .= "<td>$maintainment_day</td>";
     $texto .= "</tr>";
    }
    $texto .= "</table>";
    $texto .= '<div id="result"></div>';
    echo "<p class='total'>Total: $cont</p>".$texto;
?>
